home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DrawLine.c
-
- Contains: This application shows how to use the QuickDraw
- pattern mode 'srcCopy' to invert the intersection
- of the two green lines.
-
- Written by: Greg Henderson
-
- Copyright: Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/9/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
- #include <Controls.h>
- #include <Quickdraw.h>
- #include <Fonts.h>
- #include <Windows.h>
- #include <Menus.h>
- #include <TextEdit.h>
- #include <Dialogs.h>
- #include <Sound.h>
-
- #define KBaseResID 128
- #define kMoveToFront (WindowPtr)-1L
-
-
- /*********************/
- /* Functions */
- /*********************/
-
- void ToolBoxInit( void );
- void WindowInit( void );
- void DrawLine( void );
-
-
- /*************** main ***************/
-
- void main( void )
-
- {
- ToolBoxInit();
- WindowInit();
- DrawLine();
-
- while ( !Button() );
-
- }
-
- /*************** ToolBoxInit ***************/
-
- void ToolBoxInit( void )
-
- {
- InitGraf(&qd.thePort); /* init Quickdraw and global variables */
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( nil );
- InitCursor();
-
- }
-
- /*************** WindowInit ***************/
-
- void WindowInit( void )
-
- {
- WindowPtr window;
-
- window = GetNewCWindow( KBaseResID, nil, kMoveToFront );
-
- if ( window == nil )
- {
- SysBeep ( 10 ); /* Couldn't load the WIND resource! */
- ExitToShell();
- }
-
- ShowWindow( window );
- SetPort( window );
- }
-
- /*************** Draw two Lines ***************/
-
- void DrawLine( )
- {
- Rect pictureRect;
- WindowPtr window;
-
- window = FrontWindow();
- pictureRect = window->portRect;
-
- PenNormal() ;
- PenSize(5,5);
-
- ForeColor( blackColor );
- PenMode(srcCopy);
- MoveTo( 50, 47 );
- LineTo( 300,231 );
-
- PenMode(srcXor);
- MoveTo( 400, 47 );
- LineTo( 200,231 );
-
-
- ForeColor( greenColor );
- PenMode(addMax);
- MoveTo( 50, 47 );
- LineTo(300,231);
-
- PenMode(addMax);
- MoveTo( 400, 47 );
- LineTo( 200,231 );
-
- }
-
-